home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Applications / QuArK / plugins / mapreload.py < prev    next >
Text File  |  2004-01-05  |  4KB  |  164 lines

  1.  
  2. #$Header: /cvsroot/quark/runtime/plugins/mapreload.py,v 1.9 2003/12/18 21:51:46 peter-b Exp $
  3.  
  4. import quarkx
  5. import quarkpy.mapmenus
  6. import quarkpy.mapcommands
  7. import quarkpy.qmacro
  8. import quarkpy.mapoptions
  9.  
  10. from quarkpy.maputils import *
  11.  
  12.  
  13. prevreload = ""
  14.  
  15. class remodule:
  16.   "a place to stick stuff"
  17.  
  18. class ReloadDlg (quarkpy.qmacro .dialogbox):
  19.     #
  20.     # dialog layout
  21.     #
  22.  
  23.     endcolor = AQUA
  24.     size = (200,120)
  25.     dfsep = 0.35
  26.     flags = FWF_KEEPFOCUS
  27.     
  28.     dlgdef = """
  29.         {
  30.         Style = "9"
  31.         Caption = "Reload Dialog"
  32.  
  33.         module: =
  34.         {
  35.         Txt = "reload:"
  36.         Typ = "EP"
  37.         DefExt = "py"
  38.         BasePath = "%splugins"
  39.         DirSep = "."
  40.         CutPath = "C:\?\\"
  41.         Hint = "Type in the name of the module (.py file),"$0D
  42.                "preceded with its folder name,"$0D
  43.                "(ex. plugins.mapreload) the .py is optional,"$0D
  44.                "or just use the file browser ... to the right."$0D
  45.         }
  46.  
  47.         sep: = { Typ="S" Txt=" " }
  48.  
  49.         close:py = {Txt="" }
  50.         cancel:py = {Txt="" }
  51.  
  52.     }
  53.     """%quarkx.exepath  # suggestion by tiglari(the quotes stay)
  54.  
  55.     #
  56.     # __init__ initialize the object
  57.     #
  58.  
  59.     def __init__(self, form, editor, action):
  60.  
  61.     #
  62.     # General initialization of some local values
  63.     #
  64.  
  65.         self.editor = editor
  66.         src = quarkx.newobj(":")
  67.         self.src = src
  68.         self.action = action
  69.         self.form = form
  70.         self.src["module"] = quarkx.setupsubset(SS_MAP, "Options")["ReloadModule"]
  71.  
  72.  
  73.     #
  74.     # Create the dialog form and the buttons
  75.     #
  76.  
  77.         quarkpy.qmacro.dialogbox.__init__(self, form, src,
  78.         close = quarkpy.qtoolbar.button(
  79.             self.close,
  80.             "Reload the named module",
  81.             ico_editor, 2,
  82.             "Reload"),
  83.         cancel = quarkpy.qtoolbar.button(
  84.             self.cancel,
  85.             "Cancel & close window",
  86.             ico_editor, 0,
  87.             "Cancel"))
  88.  
  89. #    def datachange(self, df):
  90. #        self.close()   # "OK" is automatic when the user changed the data.
  91.  
  92.     def onclose(self, dlg):
  93.         if self.src is None:
  94. #            quarkx.msgbox("Empty string does not name a module, nothing done", MT_ERROR, MB_OK)
  95.             qmacro.dialogbox.onclose(self, dlg)
  96.             return
  97.         quarkx.globalaccept()
  98.         self.action(self)
  99.         qmacro.dialogbox.onclose(self, dlg)
  100.  
  101.     def cancel(self, dlg):
  102.         self.src = None 
  103.         qmacro.dialogbox.close(self, dlg)
  104.  
  105.  
  106.  
  107.  
  108. def ReloadClick(m):
  109.   def action(self):
  110.     if self.src["module"] is None:
  111.       quarkx.msgbox("Empty string does not name a module, nothing done", MT_ERROR, MB_OK)
  112.       return
  113.     module = self.src["module"]
  114.     quarkx.setupsubset(SS_MAP, "Options")["ReloadModule"] = module
  115.  
  116.     command = "reload(%s)"%module.replace(".py", "")
  117.     eval(command)
  118.     
  119.   editor=mapeditor()
  120.   if editor is None: return
  121.   ReloadDlg(quarkx.clickform,editor,action)
  122.  
  123. quarkpy.mapoptions.items.append(quarkpy.mapoptions.toggleitem("Developer Mode","Developer", hint = "|Developer Mode:\n\nIn this mode, some extra items appear on the menu, to help with debugging, etc.|intro.mapeditor.menu.html#optionsmenu"))
  124.  
  125. menreload = qmenu.item("Reload",ReloadClick,"Reload module")
  126.  
  127. if quarkx.setupsubset(SS_MAP, "Options")["Developer"]:
  128.   quarkpy.mapcommands.items.append(menreload)
  129.  
  130.  
  131. # ----------- REVISION HISTORY ------------
  132. #
  133. #
  134. # $Log: mapreload.py,v $
  135. # Revision 1.9  2003/12/18 21:51:46  peter-b
  136. # Removed reliance on external string library from Python scripts (second try ;-)
  137. #
  138. # Revision 1.8  2003/05/18 04:02:50  cdunde
  139. # To change code to avoid path hard coding
  140. #
  141. # Revision 1.7  2003/05/13 20:33:29  cdunde
  142. # To add file browser and correct closing errors
  143. #
  144. # Revision 1.6  2003/05/11 16:03:20  cdunde
  145. # To correct cancel console error
  146. #
  147. # Revision 1.5  2003/03/28 02:54:40  cdunde
  148. # To update info and add infobase links.
  149. #
  150. # Revision 1.4  2001/06/17 21:10:57  tiglari
  151. # fix button captions
  152. #
  153. # Revision 1.3  2001/03/20 08:02:16  tiglari
  154. # customizable hot key support
  155. #
  156. # Revision 1.2.4.1  2001/03/11 22:10:42  tiglari
  157. # customizable hotkeys
  158. #
  159. # Revision 1.2  2000/06/03 10:25:30  alexander
  160. # added cvs headers
  161. #
  162. #
  163. #
  164. #